﻿Imports System.Text

Namespace StatementSources

    Public Class CreateEmployeeTypeStatementSource
        Inherits BaseStatementSource

        Public Sub New(name As String, description As String, createdBy As Integer)
            Dim stringBuilder As New StringBuilder()
            stringBuilder.Append("INSERT [dbo].[EmployeeTypes] ")
            stringBuilder.Append("([Name],[Description],[CreatedBy],[CreatedDttm],[ModifiedBy],[ModifiedDttm]) ")
            stringBuilder.Append("VALUES (@Name,@Description,@CreatedBy,GETDATE(),@CreatedBy,GETDATE());")

            Sql = stringBuilder.ToString()

            Parameters.AddWithValue("@Name", name)
            Parameters.AddWithValue("@Description", description)
            Parameters.AddWithValue("@CreatedBy", createdBy)
        End Sub

    End Class

    Public Class ReadAllEmployeeTypeStatementSource
        Inherits BaseStatementSource

        Public Sub New()
            Dim stringBuilder As New StringBuilder()
            stringBuilder.Append("SELECT [EmployeeTypeId],[Name],[Description],[CreatedBy],[CreatedDttm],[ModifiedBy],[ModifiedDttm] ")
            stringBuilder.Append("FROM [dbo].[EmployeeTypes];")

            Sql = stringBuilder.ToString()
        End Sub

    End Class

    Public Class ReadByEmployeeTypeIdStatementSource
        Inherits BaseStatementSource

        Public Sub New(employeeTypeId As Integer)
            Dim stringBuilder As New StringBuilder()
            stringBuilder.Append("SELECT [EmployeeTypeId],[Name],[Description],[CreatedBy],[CreatedDttm],[ModifiedBy],[ModifiedDttm] ")
            stringBuilder.Append("FROM [dbo].[EmployeeTypes] ")
            stringBuilder.Append("WHERE [EmployeeTypeId]=@EmployeeTypeId;")

            Sql = stringBuilder.ToString()

            Parameters.AddWithValue("@EmployeeTypeId", employeeTypeId)
        End Sub

    End Class

    Public Class UpdateEmployeeTypeStatementSource
        Inherits BaseStatementSource

        Public Sub New(employeeTypeId As Integer, name As String, description As String, modifiedBy As Integer)
            Dim stringBuilder As New StringBuilder()
            stringBuilder.Append("UPDATE [dbo].[EmployeeTypes] SET ")
            stringBuilder.Append("[Name]=ISNULL(@Name,[Name]),")
            stringBuilder.Append("[Description]=ISNULL(@Description,[Description]),")
            stringBuilder.Append("[ModifiedBy]=@ModifiedBy,")
            stringBuilder.Append("[ModifiedDttm]=GETDATE() ")
            stringBuilder.Append("WHERE [EmployeeTypeId]=@EmployeeTypeId;")

            Sql = stringBuilder.ToString()

            Parameters.AddWithValue("@EmployeeTypeId", employeeTypeId)
            Parameters.AddWithValue("@Name", name)
            Parameters.AddWithValue("@Description", description)
            Parameters.AddWithValue("@ModifiedBy", modifiedBy)
        End Sub

    End Class

    Public Class DeleteEmployeeTypeStatementSource
        Inherits BaseStatementSource

        Public Sub New(employeeTypeId As Integer)
            Sql = "DELETE FROM [dbo].[EmployeeTypes] WHERE [EmployeeTypeId]=@EmployeeTypeId;"
            Parameters.AddWithValue("@EmployeeTypeId", employeeTypeId)
        End Sub

    End Class

End Namespace

